use Math::Trig;

my $windAngle;
my $windAngleRads;
my $windSpeed;
my $headWindComponent;
my $crossWindComponent;
my $runwayHeading;
my $windHeading;

RUNWAY: print "What is the active runway? ";
chomp($runwayHeading = <>);
if ($runwayHeading < 1 || $runwayHeading > 36) 
	{ print "That runway heading is out of range.  Please try again.\n"; goto RUNWAY; }
$runwayHeading = $runwayHeading . 0;
print "What is the wind direction? ";
chomp($windHeading = <>);
print "What is the wind speed? ";
chomp($windSpeed = <>);

$windAngle = $windHeading - $runwayHeading;
$windAngleRads = deg2rad($windAngle);

$crossWindComponent = sin($windAngleRads) * $windSpeed;
$headWindComponent = cos($windAngleRads) * $windSpeed;

print "_____________________________________\n";

if ($crossWindComponent < 0)
	{ printf "The crosswind component is: %.1f (Left)\n", $crossWindComponent; }
else
	{ printf "The crosswind component is: %.1f (Right)\n", $crossWindComponent; }

if ($headWindComponent < 0)
	{ printf "The headwind component is: %.1f (Tailwind) \n", $headWindComponent; }
else
	{ printf "The headwind component is: %.1f (Headwind) \n", $headWindComponent; }
